
/*
 *
 * Copyright (c) 2006 P.J.Leonard
 * 
 * http://www.frinika.com
 * 
 * This file is part of Frinika.
 * 
 * Frinika is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * Frinika is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Frinika; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package uk.ac.bath.base;

import java.util.Comparator;

/**
 *
 * @author pjl
 */
public class AbstractGene implements Comparable {

    public float fitness;
    public int tests;
    static long count = 0;
    long id;

    public AbstractGene() {

        id = count++;

    }

    public int compareTo(Object oo) {

        Gene o = (Gene) oo;
        if (fitness > o.fitness) {
            return 1;
        } else if (fitness < o.fitness) {
            return -1;
        }

        if (id > o.id) {
            return 1;
        } else if (id < o.id) {
            return -1;
        }

        return 0; // same Gene !!!!

    }
    public static Comparator<AbstractGene> rev = new ReverseComp();

    public static class ReverseComp implements Comparator<AbstractGene> {

        public int compare(AbstractGene o1, AbstractGene o2) {
            return o2.compareTo(o1);
        }
    }
}
